package com.example.mapper;

import com.example.entity.DTO.DepartmentDetailDTO;
import com.example.entity.Department;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DepartmentMapper {
    /**
     * 根据名称查询部门详细信息
     * @param name
     * @return
     */
    List<DepartmentDetailDTO> selectAllDeptByName(String name);

    /**
     * 根据id查询部门
     */
    @Select("select * from `department` where id = #{id}")
    Department selectById(Integer id);

    /**
     * 根据名称查询部门
     */
    @Select("select * from `department` where name = #{name}")
    Department selectByName(String name);

    /**
     * 添加部门
     * @param department
     */
    void insert(Department department);

    /**
     * 根据id更新部门
     * @param department
     */
    void updateById(Department department);

    /**
     * 删除部门
     * @param id
     */
    @Delete("delete from `department` where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据名称查询部门详细信息
     * @param name
     * @return
     */
    @Select("select * from `department` where name = #{name}")
    DepartmentDetailDTO selectDeptByName(String name);
}
